package com.zk.shop.servlet.order;

import com.zk.shop.entity.Goods;
import com.zk.shop.entity.Order;
import com.zk.shop.entity.User;
import com.zk.shop.service.Impl.OrderServiceImpl;
import com.zk.shop.service.OrderService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("EndOrderServlet")
public class EndOrderServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        int orderId= Integer.parseInt(req.getParameter("orderId"));
        int state= Integer.parseInt(req.getParameter("state"));
        OrderService orderService=new OrderServiceImpl();
        Order o=orderService.selOneOrder(orderId);
        Order order=new Order();
        order.setOrderNum(o.getOrderNum());
        order.setState(state);
        boolean flag=orderService.updateOrder(order);

        PrintWriter out=resp.getWriter();
        if (flag){
            out.print("true");
        }else{
            out.print("false");
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
